package com.xujie.property_warranty_system.enums;

import lombok.Getter;

/**
 * 设施设备状态枚举
 */
@Getter
public enum FacilityStatus {
    
    NORMAL(1, "正常"),
    MAINTAINING(2, "维修中"),
    SCRAPPED(3, "报废");
    
    private final Integer code;
    private final String description;
    
    FacilityStatus(Integer code, String description) {
        this.code = code;
        this.description = description;
    }
    
    /**
     * 根据状态码获取枚举
     */
    public static FacilityStatus fromCode(Integer code) {
        for (FacilityStatus status : FacilityStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return NORMAL; // 默认返回正常状态
    }
}
